package com.wisdudu.blank.ui.login;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import com.wisdudu.blank.R;
import com.wisdudu.blank.support.rxbus.RxBusFlag;
import com.wisdudu.blank.support.view.IndicatorView;
import com.wisdudu.blank.ui.common.adapter.GuideAdapter;

/**
 * Created by qyf on 2016/10/9.
 */
public class GuideActivity extends AppCompatActivity {

    private IndicatorView mIndicatorView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        mIndicatorView = (IndicatorView) findViewById(R.id.indicator_view);
        GuideAdapter guideAdapter = new GuideAdapter(this, getIntent().getStringExtra(RxBusFlag.FLAG_GUIDE_FROM));
        mIndicatorView.setEnabled(true);
        mIndicatorView.init(4);
        viewPager.setAdapter(guideAdapter);
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                mIndicatorView.selectTo(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        mIndicatorView.selectTo(0);
    }

}
